package top.goldenyear.porpoise.system.permission.controller.admin;

import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.*;
import org.noear.solon.validation.annotation.Validated;
import top.goldenyear.porpoise.common.core.model.Ret;
import top.goldenyear.porpoise.framework.web.core.controller.BaseController;
import top.goldenyear.porpoise.system.permission.dto.RolePermissionDto;
import top.goldenyear.porpoise.system.permission.service.RolePermissionService;

/**
 * 角色权限表 Controller 控制层
 *
 * @author airhead
 * @since 2024-10-13
 */
@Component(tag = "adminApi")
@Mapping("/permission/rolePermission")
@Slf4j
public class RolePermissionAdminController extends BaseController {
  @Inject private RolePermissionService service;

  @Post
  @Put
  @Mapping("update")
  public Ret update(@Validated @Body RolePermissionDto rolePermissionDto) {
    return Ret.okWithData(service.updateRolePermission(rolePermissionDto));
  }

  @Get
  @Mapping("list")
  public Ret list(Integer roleId) {
    return Ret.okWithData(service.listRolePermission(roleId));
  }
}
